import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by dell on 2017/12/21.
 */
public class Day20171221 {

    public static void main(String[] args) {
        Map<String, Integer> map = new HashMap<>();

        String stuNo = "";

        //字符流的方式读文件
        String psth = "E:\\大二第一学期各科作业\\java\\data\\names.txt";

        BufferedReader reader = null;

        try {
            reader = new BufferedReader(new FileReader(psth));
            try {
                while ((stuNo = reader.readLine()) != null)

                    map.put(stuNo, 0);
            } catch (IOException e) {
                e.printStackTrace();
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } finally {
            try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        //从文件夹下获取所有文件
        File file = new File("E:\\大二第一学期各科作业\\java\\data\\16信本2班Java作业一");

        File[] files = file.listFiles();

        //遍历每一个文件
        for (File f : files) {

            //先得到文件名
            String fileName = f.getName();

            //保存提取到的学号
            String no = "";

            //从文件中提取学号
            //从正则表达式中：1 模板。2 三个填空
            Matcher matcher = Pattern.compile("2016级信本2班(//d+)").matcher(fileName);
            while (matcher.find()) {

                no = matcher.group(1);
            }
            map.put(no, 1);
        }
        //把value为0 的打印出来
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            if (entry.getValue() == 0) {

                System.out.println(entry.getKey());
            }
        }

    }
}


